import Taro from "@tarojs/taro";
import { useEffect, useState } from "react";

/*
  获取系统导航栏的hook
 */
const defaultHeight = 20;
export const useStatusBarHeight = (): number => {
  const [statusBarHeight, setStatusBarHeight] = useState<number>(defaultHeight);
  useEffect(() => {
    Taro.getSystemInfo({
      success: function (res) {
        setStatusBarHeight(res.statusBarHeight || defaultHeight);
      },
    });
  }, []);

  return statusBarHeight;
};
